﻿<template>
  <a-modal
    title="新增人员信息"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="EMP_CODE " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入EMP_CODE " v-decorator="['empCode']" />
        </a-form-item>
        <a-form-item label="EMP_NAME " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入EMP_NAME " v-decorator="['empName']" />
        </a-form-item>
        <a-form-item label="INPUT_CODE " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入INPUT_CODE " v-decorator="['inputCode']" />
        </a-form-item>
        <a-form-item label="EMP_SEX " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入EMP_SEX " v-decorator="['empSex']" />
        </a-form-item>
        <a-form-item label="EMP_BIRTHDAY " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入EMP_BIRTHDAY " v-decorator="['empBirthday']" />
        </a-form-item>
        <a-form-item label="BIRTH_PLACE " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入BIRTH_PLACE " v-decorator="['birthPlace']" />
        </a-form-item>
        <a-form-item label="CITIZENSHIP " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入CITIZENSHIP " v-decorator="['citizenship']" />
        </a-form-item>
        <a-form-item label="NATION " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入NATION " v-decorator="['nation']" />
        </a-form-item>
        <a-form-item label="ID_NO " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入ID_NO " v-decorator="['idNo']" />
        </a-form-item>
        <a-form-item label="MAILING_ADDRESS " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入MAILING_ADDRESS " v-decorator="['mailingAddress']" />
        </a-form-item>
        <a-form-item label="ZIP_CODE " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入ZIP_CODE " v-decorator="['zipCode']" />
        </a-form-item>
        <a-form-item label="PHONE_NUMBER_HOME " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入PHONE_NUMBER_HOME " v-decorator="['phoneNumberHome']" />
        </a-form-item>
        <a-form-item label="PHONE_NUMBER_BUSINESS " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入PHONE_NUMBER_BUSINESS " v-decorator="['phoneNumberBusiness']" />
        </a-form-item>
        <a-form-item label="EMP_JOB " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入EMP_JOB " v-decorator="['empJob']" />
        </a-form-item>
        <a-form-item label="EMP_TITLE " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入EMP_TITLE " v-decorator="['empTitle']" />
        </a-form-item>
        <a-form-item label="DOCT_ATTR " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入DOCT_ATTR " v-decorator="['doctAttr']" />
        </a-form-item>
        <a-form-item label="DOCT_COUNTERMARK_NO " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入DOCT_COUNTERMARK_NO " v-decorator="['doctCountermarkNo']" />
        </a-form-item>
        <a-form-item label="SYS_USER_CODE " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入SYS_USER_CODE " v-decorator="['sysUserCode']" />
        </a-form-item>
        <a-form-item label="VIP_INDICATOR " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入VIP_INDICATOR " v-decorator="['vipIndicator']" />
        </a-form-item>
        <a-form-item label="CREATE_OPERATOR " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入CREATE_OPERATOR " v-decorator="['createOperator']" />
        </a-form-item>
        <a-form-item label="MODEFY_OPERATOR " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入MODEFY_OPERATOR " v-decorator="['modefyOperator']" />
        </a-form-item>
        <a-form-item label="MODEFY_DATE " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择MODEFY_DATE " v-decorator="['modefyDate']" @change="onChangemodefyDate"/>
        </a-form-item>
        <a-form-item label="INPUT_CODE_WB " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入INPUT_CODE_WB " v-decorator="['inputCodeWb']" />
        </a-form-item>
        <a-form-item label="DEPT_CODE " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入DEPT_CODE " v-decorator="['deptCode']" />
        </a-form-item>
        <a-form-item label="DEPT_NAME " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入DEPT_NAME " v-decorator="['deptName']" />
        </a-form-item>
        <a-form-item label="NURSE_STATION_CODE " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入NURSE_STATION_CODE " v-decorator="['nurseStationCode']" />
        </a-form-item>
        <a-form-item label="NURSE_STATION_NAME " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入NURSE_STATION_NAME " v-decorator="['nurseStationName']" />
        </a-form-item>
        <a-form-item label="创建时间" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择创建时间" v-decorator="['createDate']" @change="onChangecreateDate"/>
        </a-form-item>
        <a-form-item label="创建者Id" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入创建者Id" v-decorator="['createUserId']" />
        </a-form-item>
        <a-form-item label="创建者名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入创建者名称" v-decorator="['createUserName']" />
        </a-form-item>
        <a-form-item label="更新时间" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择更新时间" v-decorator="['modifyDate']" @change="onChangemodifyDate"/>
        </a-form-item>
        <a-form-item label="修改者Id" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入修改者Id" v-decorator="['modifyUserId']" />
        </a-form-item>
        <a-form-item label="修改者名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入修改者名称" v-decorator="['modifyUserName']" />
        </a-form-item>
        <a-form-item label="删除时间" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-date-picker style="width: 100%" placeholder="请选择删除时间" v-decorator="['deleteDate']" @change="onChangedeleteDate"/>
        </a-form-item>
        <a-form-item label="删除者ID" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入删除者ID" v-decorator="['deleteUserId']" />
        </a-form-item>
        <a-form-item label="删除者姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入删除者姓名" v-decorator="['deleteUserName']" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
  import {
    SysEmpInfoAdd
  } from '@/api/modular/main/SysEmpInfoManage'

  export default {
    data () {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 }
        },
        modefyDateDateString: '',
        createDateDateString: '',
        modifyDateDateString: '',
        deleteDateDateString: '',
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
      // 初始化方法
      add (record) {
        this.visible = true
      },
      /**
       * 提交表单
       */
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
            }
            values.modefyDate = this.modefyDateDateString
            values.createDate = this.createDateDateString
            values.modifyDate = this.modifyDateDateString
            values.deleteDate = this.deleteDateDateString
            SysEmpInfoAdd(values).then((res) => {
              if (res.success) {
                this.$message.success('新增成功')
                this.confirmLoading = false
                this.$emit('ok', values)
                this.handleCancel()
              } else {
                this.$message.error('新增失败：' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          } else {
            this.confirmLoading = false
          }
        })
      },
      onChangemodefyDate(date, dateString) {
        this.modefyDateDateString = dateString
      },
      onChangecreateDate(date, dateString) {
        this.createDateDateString = dateString
      },
      onChangemodifyDate(date, dateString) {
        this.modifyDateDateString = dateString
      },
      onChangedeleteDate(date, dateString) {
        this.deleteDateDateString = dateString
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
